#coding:utf-8

from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, TextAreaField,DateTimeField , SubmitField
from wtforms.validators import Required,Length,EqualTo
from flask_wtf.file import FileField, FileRequired, FileAllowed

from .. import files

class LoginForm(FlaskForm):
    xh = StringField(u'学号',validators=[Required()])
    password = PasswordField(u'密码',validators=[Required()])
    submit = SubmitField(u'登录')


class FileForm(FlaskForm):
    file = FileField(validators=[
        FileRequired(u'未选择文件'),
        FileAllowed(files,u'请勿上传非法文件')]) 
    submit = SubmitField(u'上传')

class TaskForm(FlaskForm):
    taskName = StringField(u'任务名',validators=[Required(),Length(2,64)])
    taskDescription = TextAreaField(u'任务描述')
    taskDeadLine = DateTimeField(u'截止时间')
    submit = SubmitField(u'添加')

class PasswordForm(FlaskForm):
    current = PasswordField(u'当前密码',validators=[Required()])
    new = PasswordField(u'新密码',validators=[Required(),EqualTo('confirm')])
    confirm = PasswordField(u'确认密码',validators=[Required()])
    submit = SubmitField(u'修改')